// 设置cookie
				function setCookie(key,value,time){
					document.cookie = `${key}=${value};Max-Age=${time};`;
				}
				// 删除cookie 
				function delCookie(key){
					document.cookie = `${key}='';Max-Age=-1`;
				}
				
				// 获取cookie
				function getCookie(key){
					let cookiestr = document.cookie; // uname=zhangsn; age=20
					let arr = cookiestr.split("; ");
					let result;
					for(let i=0;i<arr.length;i++){
						let res = arr[i].split("=");  //uname=zhangsn  , age=20
						if(res[0]==key){
							result = res[1];
						}
					}
					return result;
				}
				
				function ajax(options) {
					// 默认参数  
					// 合并配置
					return new Promise((res, rej) => {
						let {
							url = "", method = "get", data = {}, async = true, dataType = 'text'
						} = options;
						// console.log(url,method,data,async,dataType,success);
						let xhr = new XMLHttpRequest();
						if (method.toLowerCase() == 'get') {
							url = url + "?" + o2s(data);
						}
						if (method.toLowerCase() == "post") {
							xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded")
						}
						xhr.open(method, url, async);
						xhr.onload = function() {
							if (dataType.toLowerCase()== "text") {
								// success(xhr.responseText);
								res(xhr.responseText)
							} else if (dataType.toLowerCase() == "json") {
								// success(JSON.parse(xhr.responseText));
								res(JSON.parse(xhr.responseText))
							}
				
						}
						xhr.onerror = function(err) {
							rej(err);
						}
						xhr.send(o2s(data));
					})
				
				
					// 子函数；
					function o2s(obj) {
						let keys = Object.keys(obj);
						let values = Object.values(obj);
						return keys.map((item, k) => item + "=" + values[k]).join("&");
					}
				
				}

